package com.aiyige.page.photoview;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ImageView;

import com.aiyige.R;
import com.aiyige.arouter.config.ARouterConfig;
import com.alibaba.android.arouter.facade.annotation.Autowired;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions;
import com.bumptech.glide.request.RequestOptions;
import com.github.chrisbanes.photoview.OnPhotoTapListener;
import com.github.chrisbanes.photoview.PhotoView;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

@Route(path = ARouterConfig.PhotoViewPage)
public class PhotoViewPage extends AppCompatActivity {

    @BindView(R.id.photoView)
    PhotoView photoView;

    @Autowired
    String photoUrl;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.page_photo_view);
        ButterKnife.bind(this);
        ARouter.getInstance().inject(this);
        Glide.with(this)
                .load(photoUrl)
                .apply(RequestOptions.placeholderOf(R.drawable.default_image_bg))
                .transition(DrawableTransitionOptions.withCrossFade())
                .into(photoView);
        photoView.setOnPhotoTapListener(new OnPhotoTapListener() {
            @Override
            public void onPhotoTap(ImageView view, float x, float y) {
                finish();
            }
        });
    }
}
